package com.jia.product.controller;


import com.jia.product.entity.Brand;
import com.jia.product.entity.Category;
import com.jia.product.service.CategoryService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商品三级分类(Category)表控制层
 *
 * @author makejava
 * @since 2025-07-08 18:15:26
 */
@RestController
@RequestMapping("category")
public class CategoryController {

    /**
     * 服务对象
     */
    @Resource
    private CategoryService categoryService;

    @GetMapping("/tree")
    public List<Category> tree() {
        return categoryService.treeList();
    }

    @PostMapping("/insert")
    public String insert(@RequestBody List<Category> categoryList) {
        categoryService.saveBatch(categoryList);
        return "success";
    }

    @PutMapping("/update")
    public String update(@RequestBody Category category) {
        categoryService.updateByIdRelation(category);
        return "success";
    }

    @PostMapping("/delete")
    public String delete(@RequestBody List<String> idList) {
        categoryService.updateShowStatusListById(idList);
        return "success";
    }


}

